import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;

class  player{
    private String name;
    private ArrayList<String> poker = new ArrayList<>();

    public player() {
    }

    public player(String name, ArrayList<String> poker) {
        this.name = name;
        this.poker = poker;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return poker
     */
    public ArrayList<String> getPoker() {
        return poker;
    }

    /**
     * 设置
     * @param poker
     */
    public void setPoker(ArrayList<String> poker) {
        this.poker = poker;
    }

    public String toString() {
        return "player{name = " + name + ", poker = " + poker + "}";
    }

//    public String sort(){
//        //todo
//    }
}


public class Fight_landlords {
    public static void main(String[] args) {
        int numCard=54,numPerson=17;

        String[] colors={"♠","♥","♣","♦"};
        String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};

        ArrayList<String> poker = new ArrayList<>();

        poker.add("Big_joker");
        poker.add("Small_joker");
        for(String number:numbers) {
            for (String color : colors) {
                poker.add(color + number);
            }
        }
//        System.out.println(poker);//

        Collections.shuffle(poker);
//        System.out.println(poker);

        player p1=new player();p1.setName("aaa");
        player p2=new player();p2.setName("bbb");
        player p3=new player();p3.setName("ccc");
        ArrayList<String> dipai=new ArrayList<>();

        for(int i=0;i<poker.size();i++){

            String p = poker.get(i);
            if(i>=51){
                dipai.add(p);
            }else if(i%3==0){
                p1.getPoker().add(p);
            }else if(i%3==1){
                p2.getPoker().add(p);
            }else if(i%3==2){
                p3.getPoker().add(p);
            }
        }


//        System.out.println(p1.getName()+"  poker:"+p1.getPoker());
//        System.out.println(p2.getName()+"  poker:"+p2.getPoker());
//        System.out.println(p3.getName()+"  poker:"+p3.getPoker());
//        System.out.println("dipai : "+dipai);

        System.out.println("======================");
        //排序
        Collections.sort(p1.getPoker(), new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                char c1;
                char c2;

                if(o1.length()==2){
                    c1=o1.charAt(1);//3和K等
                    if(c1=='K'){
                        c1='R';//保证K>Q>J
                    }else if(c1=='A'){
                        c1='a';
                    }else  if(c1=='2'){
                        c1='b';
                    }

                } else if(o1.length()==3){
                    c1=':';
                } else {//                if(o1.length()>3)
                    c1 = o1.charAt(1);
                    if(c1 == 'i'){
                        c1='}';
                    }else if( c1 == 'm'){
                        c1='{';
                    }
                }//对c1赋值

                if(o2.length()==2){
                    c2=o2.charAt(1);//3和K等
                    if(c2=='K'){
                        c2='R';//保证K>Q>J
                    }else if(c2=='A'){
                        c2='a';
                    }else  if(c2=='2'){
                        c2='b';
                    }
                } else if(o2.length()==3){
                    c2=':';
                } else {//                if(o2.length()>3)
                    c2 = o2.charAt(1);
                    if(c2 == 'i'){
                        c2='}';
                    }else if( c2 == 'm'){
                        c2='{';
                    }
                }

                return c1-c2;
            }


//        HashMap<int,>

        });
        Collections.sort(p2.getPoker(), new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                char c1;
                char c2;

                if(o1.length()==2){
                    c1=o1.charAt(1);//3和K等
                    if(c1=='K'){
                        c1='R';//保证K>Q>J
                    }else if(c1=='A'){
                        c1='a';
                    }else  if(c1=='2'){
                        c1='b';
                    }

                } else if(o1.length()==3){
                    c1=':';
                } else {//                if(o1.length()>3)
                    c1 = o1.charAt(1);
                    if(c1 == 'i'){
                        c1='}';
                    }else if( c1 == 'm'){
                        c1='{';
                    }
                }//对c1赋值

                if(o2.length()==2){
                    c2=o2.charAt(1);//3和K等
                    if(c2=='K'){
                        c2='R';//保证K>Q>J
                    }else if(c2=='A'){
                        c2='a';
                    }else  if(c2=='2'){
                        c2='b';
                    }
                } else if(o2.length()==3){
                    c2=':';
                } else {//                if(o2.length()>3)
                    c2 = o2.charAt(1);
                    if(c2 == 'i'){
                        c2='}';
                    }else if( c2 == 'm'){
                        c2='{';
                    }
                }

                return c1-c2;
            }


//        HashMap<int,>

        });
        Collections.sort(p3.getPoker(), new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                char c1;
                char c2;

                if(o1.length()==2){
                    c1=o1.charAt(1);//3和K等
                    if(c1=='K'){
                        c1='R';//保证K>Q>J
                    }else if(c1=='A'){
                        c1='a';
                    }else  if(c1=='2'){
                        c1='b';
                    }

                } else if(o1.length()==3){
                    c1=':';
                } else {//                if(o1.length()>3)
                    c1 = o1.charAt(1);
                    if(c1 == 'i'){
                        c1='}';
                    }else if( c1 == 'm'){
                        c1='{';
                    }
                }//对c1赋值

                if(o2.length()==2){
                    c2=o2.charAt(1);//3和K等
                    if(c2=='K'){
                        c2='R';//保证K>Q>J
                    }else if(c2=='A'){
                        c2='a';
                    }else  if(c2=='2'){
                        c2='b';
                    }
                } else if(o2.length()==3){
                    c2=':';
                } else {//                if(o2.length()>3)
                    c2 = o2.charAt(1);
                    if(c2 == 'i'){
                        c2='}';
                    }else if( c2 == 'm'){
                        c2='{';
                    }
                }

                return c1-c2;
            }


//        HashMap<int,>

        });

        System.out.println(p1.getName()+"  poker:"+p1.getPoker());
        System.out.println(p2.getName()+"  poker:"+p2.getPoker());
        System.out.println(p3.getName()+"  poker:"+p3.getPoker());
        System.out.println("dipai : "+dipai);
    }
}